#include <matrix.h>
#include <cuda02.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
using namespace std;
int main() {
    
	cudaDeviceProp deviceProp;
	int deviceCount;
	cudaError_t cudaError;
	cudaError = cudaGetDeviceCount(&deviceCount);
    std::cout << "deviceCount:\t" << deviceCount << std::endl;
	for (int i = 0; i < deviceCount; i++)
	{
		cudaError = cudaGetDeviceProperties(&deviceProp, i);

		cout << "设备 " << i + 1 << " 的主要属性： " << endl;
		cout << "设备显卡型号： " << deviceProp.name << endl;
		cout << "设备全局内存总量（以MB为单位）： " << deviceProp.totalGlobalMem / 1024 / 1024 << endl;
		cout << "设备上一个线程块（Block）中可用的最大共享内存（以KB为单位）： " << deviceProp.sharedMemPerBlock / 1024 << endl;
		cout << "设备上一个线程块（Block）种可用的32位寄存器数量： " << deviceProp.regsPerBlock << endl;
		cout << "设备上一个线程块（Block）可包含的最大线程数量： " << deviceProp.maxThreadsPerBlock << endl;
		cout << "设备的计算功能集（Compute Capability）的版本号： " << deviceProp.major << "." << deviceProp.minor << endl;
		cout << "设备上多处理器的数量： " << deviceProp.multiProcessorCount << endl;
	}

    const int arraySize = 16;
    const int a[arraySize] = { 2, 3, 4, 6, 3, 5, 6, 9, 4, 1, 7, 2, 5, 7, 3, 12 };
    const int b[arraySize] = { 3, 5, 3, 7, 9, 3, 9, 3, 3, 8, 3, 3, 6, 16, 27, 30 };
    const int a1[arraySize] = { 21, 3, 4, 6, 3, 5, 6, 9, 4, 1, 7, 2, 5, 7, 3, 12 };
    const int b1[arraySize] = { 31, 5, 3, 7, 9, 3, 9, 3, 3, 8, 3, 3, 6, 16, 27, 30 };
    int out[arraySize] = { 0 };

    // Add vectors in parallel.
    mat4x4_mul_gpu(a, b, out, arraySize);

    printf("out = [\n\t[ %d, %d, %d, %d ],\n"
        "\t[ %d, %d, %d, %d ],\n"
        "\t[ %d, %d, %d, %d ],\n"
        "\t[ %d, %d, %d, %d ]\n]\n",
        out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8], out[9], out[10], out[11], out[12], out[13], out[14], out[15]);

    mat4x4_mul_cpu(a, b, out);

    printf("out = [\n\t[ %d, %d, %d, %d ],\n"
        "\t[ %d, %d, %d, %d ],\n"
        "\t[ %d, %d, %d, %d ],\n"
        "\t[ %d, %d, %d, %d ]\n]\n",
        out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8], out[9], out[10], out[11], out[12], out[13], out[14], out[15]);

    //calc();
    return 0;
}